{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 15.6. Finding a Boolean propositional formula from a truth table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy import *\n",
    "init_printing()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "podoc": {
     "output_text": "(x, y, z)"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAABTBAMAAAAmd74uAAAAMFBMVEX///92dnaIiIhUVFSYmJgi\nIiJERES6urpmZmYQEBDMzMwyMjLc3Nzu7u6qqqoAAAA1ApXJAAAAAXRSTlMAQObYZgAAAAlwSFlz\nAAAOxAAADsQBlSsOGwAAB09JREFUeNrdXEFrJEUUrpnMZJJJ9yQXBUXIgCdBmFz25ELHiydD1j2s\nCi69Fw8r6OSkx4k/QDoiKoEsnat4GEGQvcgMexCC4AzKsu7FBDyuMplkOpueSeZZXd1V3VXdcZuu\n2sP0u2TS7LyqV++973vvVWcRovIvmm0pxR/9Op1xm3rfik+q9vas+wmOhCetMzTr0hjxv9fgh5m3\naQFWeDe5/Zm3CTU5R2lwMfsmoTJsRX57COs5sIn3jHGG8iANJ/xczEXoIbQEISH1chF6XvA9DQFj\ngvIhlhsy8NOc2HTIgm8xB4RLaZcCQyNWKc2q6HAafLAdlBcxYJ/8LMAoNza14E6QTpe5sakcJFQL\n1nJjUxHOfXbKDUR4IAF98sNF+RGTlERFin+5kFUCEuUcwR5CbQJ47ZwU5b4sEw81YCdHNs2TTGrG\noFx70fxmg3x4AW4pwcS37K+2lG+/9qHzhf/pIGybCuAVRbbYPFWb4AKZwazCLkBdfvXvsZ4QiF5T\n01RXbIBgAGGGe6x5YK4BCEe46byN/gS88Ly7gSrGufzqcB1tsi6goOSYvJzBQpqkghNtCzHblnyW\nitbr6+Qba8jALUjJDKpCGSyaerk7Zp1NpMPOLiUg4m2uNY48t7H2OZF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Rpeq5G6ElGYwNeQb/gr/94TZwT10gg\nWBTifML3gLG55l+Looen0VPNXn0GxT9WH9KThMYKfECUEjkVWOiMkNRlpH5wsdVzTnAZXwnRhVyN\nbGdOaaJON76O0JOExsVJnx6KyA1lEgiH0YBsTLZQzbztRcnH6K/mMHrUYGemlqoNHyHtJecguoXs\nGi0fvTueSUOxSRoTcyOPa7Z3Tdknp7gLk0i/UezcPMzeJv4B3n1qnRvuZdaoBWlIUGZLbJJukBiI\nok/lDfs98o3SXfe+kMHLEq3vg7twa8Mb7nXlNVYozjzZvb8VG7rV/VI5JfocSpc1TQG95TXGu8++\nb1rKNr23LblgrNOQ1hhvKE6DjiPlSx8D2REFTtILtRpFmQ8AbyltS2NlHFHon8X6KEmNV6dH4J9K\n2qtAO6NJBtwOinwBIrJqvFo2Ka52oJuKZCZZ44G2nR2h/6wqf1ffdlkLnypVF0ZZzy5AuxJEyjAZ\njf+TsCN2kKle8n2csetu0mL8scgaj48V21Rmh6alu8OwMoKUSQc2htgvWSvK02k/LN1TJJSW9c/z\nOkGpWhTLcE35H/zZ55E+NEWNspR12mLAzeAQTxRpvDLjI6+0aHaKZLWyVnutHdpvrivSeOUwKTrk\nbz17MlnKHCjzZ943tSZp5JRovDJzTzgMfGYx2co8P9XN4T76rRmb97bGik0q8FZYz3yb8klXIsw9\n+bKvTuMV9ehE4Po6en7yO26eXkbPW6r8S28YcGf9vyXw7tj64sRsf8ZN0s3YHZu1N+M2leN3bLV3\nZz30GCL8B6VwNYaf4SBiAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "(x, y, z)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "var('x y z')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "podoc": {
     "output_text": "Formula"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAawAAABTBAMAAAAxVS7nAAAAMFBMVEX///8yMjJUVFS6urpmZm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jN1t3JglLmoiAMi9mn9x8wKMpuP6romJlsUeFt\n7fSzka1dvjk1WOkIf5k7eWt6MYgLmv8AkD2wPvKRoXcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "Formula"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "P = x & (y | ~z)\n",
    "P"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "podoc": {
     "output_text": "False"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALIAAAA7BAMAAAAtG81LAAAAMFBMVEX///+YmJjMzMwiIiJ2dnbu\n7u4QEBAyMjJERERUVFRmZmbc3NyIiIiqqqq6uroAAADoGcIdAAAAAXRSTlMAQObYZgAAAAlwSFlz\nAAAOxAAADsQBlSsOGwAABMBJREFUWMO1mEtoG0cYgEe21rG9luxLWgJpJQjtpaUKgTRtSZBJeykE\nor6cgygqSUshlzUEQpoHNg3kAQE5p4Q2IB96yINgtYceSlo7j0MPBfvSphiCDS29pCDba+9aju0/\nM7Mz/8xKs4qMrblotfvvt7P/+19CNrjyb71Ktn7ZN084AMtNSlfAuKZMskl+aZPkic2Tf7l9fYjf\ncPk2X9dP8n+jRmHrt7HmyUz+MEU9w7+/0rthOEI2sSEy6Qij2JN2R8lujLyNkkfC+pyLknU2RO6s\nIZMMLEXJZjdH7oGFKNmhzZFJdq1V5MnVVpELK60ib1tuFTnutoqcgFaRLci1iEwg3Sry0NSWkx8H\nmbk0seXkyeDg5b4tJx/W1fLmeefYlXIk+d/zjnt6liSPK8vvOOmdOmgmj2nkhwDHANwpM5mm8eXv\nbma9vhl8VrII3tsA+43kkiLvgrNl0jYG7qyRPAN3GP+hC76s7UX4skw+cmCPieyMqGg5wMWzsGoi\nx+GM2AuSU1BlYdCtSr9GtpX7VapYcUYM5JQrgqlLknsA+gONwlo9uRMpljMsD/RNS7IF65jMBXkM\n1F7SdeQSknvA7ZcvqUWkJMdVqUz5sqyLutwGMBgmW6whkOR2rNIdemWX5HZ5MyG9AXlcqbcI84qM\nS5J76XHgFNQiS3XkgmocOn1xBVPvjDw0kgvYg9HXnK8jZ5Q24r6QQnP0yk0x8nu087p1oWbPfcJf\nYNFAxnMxX5htQXPj0RoLfqrIXfRkTriBNHpIG6jVZFW0nl/gW0hjar7xuvK6IfRKveOSZGrWqswo\nTwOfU3ZOyCZLI8dUVCTv55DsG7yOnt0eastUA5uUmtGju7YERJEtbu53H+A8oDfd1KHX68jFJsks\nftjyD6IC1KBAH7vWKNcxkf+DTt1A7pFuegD/vnNJrIvST6PyM7mXpVe8fUYy+Uuiz0i96+tow5ry\nmGJvpCO0QaySgHizwknTzdRBtv6hxKlIPVP07wK9EKSAF5Dz2MJQWTdNGpCpQ+zI8k3nAm2km+k3\neKTIk5FkKjUtJrGYcYg0kttVTDcgU6TDAy6BaeaF5BKmbyN5AAOui7uYZRxPTWQWU+UG5MyctocV\nfsEQviZyl5bgONn+JkSurGvjJDs1qeW6huQCqBLKyW1emKzmjTivION65SFt30eSK2ratI1kTxtM\nfVQ3jiNrkeSUIieNZOW9Ntcbfb42gmTmIsma2rrN5FGVM1dF6ldtWnE4kjyj9tzByUm3hrykKsiC\nCIBB9bAyTvS1nx3GlQUnU+w9Y8uidPiCXFVuNCh6KSy6AysYbupxyuuEE9vVXlZr44vCT1xp4T6c\n/2fFL54qDuKb63YNeI6U+/mrbtYKFp4FdVJosyLLBrGyi3iLOPqEdZOfP9n5Pk+F1T9eefJn6EtE\nYJgYpGnkzudpGbMffchym//DoRzThug8d6GNjgB8G9SXvbVfqNb1TRcBzhHyY/Zo8FJ+TnyhAh73\nFZj4z6P11f5b61RfAjj7ND/Noz2azEYDNhuwF0w44E2QEDmzSOwSnx1WyqH5g30d467+8RufyVSb\n/+m1cIaevua4V3klSHxQm3sH+llRcbx9d0PT7r2Lztc3+JnnbTyKfHyPnrkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "False"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "P.subs({x: True, y: False, z: True})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "minterms = [[1, 0, 1], [1, 0, 0], [0, 0, 0]]\n",
    "dontcare = [[1, 1, 1], [1, 1, 0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "podoc": {
     "output_text": "SOP form"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeMAAABTBAMAAABe5HLKAAAAMFBMVEX///8yMjJUVFS6urpmZmaI\niIjMzMyqqqru7u6YmJgQEBAiIiJERER2dnbc3NwAAAArXmsiAAAAAXRSTlMAQObYZgAAAAlwSFlz\nAAAOxAAADsQBlSsOGwAACYRJREFUeNrNXEtrG1cUHus5elg2TRelFGToptCFTDaBQqusQnfyDyiV\nd4VQsNsuCk1AIoEu4oJEt22Ruyi4gWa0Kn1mvGuT0MilULqKRKGbPHCs2K49I/t07jzuvM7M3HHv\nCN2VbOQ799xzzvd959w7FgTeI98WZnF0k5u6Ul2fRYsrynJic1/en0knC71/k5o5DduzaXIWkgrt\n1p4wo6NxkpSTt2bV5HJCbt6F0ayaLMjPkphVlI9n1uKE3JGaVfAyAKyfwKzNGY5rQagmwJ8VmOG4\nJpHNX46UYXGWTc7AJivxPMB++zoipXuct7HyB19wBdbI3lVZVZbEWYfMwSpfNcIKNR1Y8f+yhJic\nBc46ts45UTqwxJqhm9hq/AXTDd4sMIBDzhzKOF8ac95A8f9uyFnSVQDGnOXwhFWp7SGrOUBSGfh2\nBzIAnHleZp2v50eRDBwhe8jXJ1rq1WCHs1S6yPbFoj/rO8jflnmj1xD+hqecN/GI7YvzcOpfzQiZ\nb5OvydI4x1nOlVjnE8FXXUsTLGqWuK6voOFrVeU65TwzftUAWQ2CDV3OLlkUWsC1eZgDVoTd9YqR\nEqIRcrzhlVB/kbMYAVa3+MQIJkSyoHAWIg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FtAjML3ZVzBwgblaXvZFoGHD+RfWS/uFz6ctLEegf1lLuxbmb\nXHlLUu+0C+D3XholpAbzNZm0tWPv3Xx+2YflB0LM8XgptIcQ+8JSGatYf8eQKnVf4DAWmC93sNJh\n7LcKO8Da4+EzWpzvXObi33XrwXRfrBrwfm2oykqe15cFb908lSHyvoCo0TZb2FwD414D6aScTtPk\nQnz0ihhzjAYMrG7CHLDeguczirxvjGvJvM+21xZO90CdpsXa87r80YFFcpYtHShKnO/hRheV3Kdk\nu+NQMm8GkSKvO91U5r/DbG25OasB0+SOJlGpnAByVFnK2hSoK2ZOT1WHCA2lzX/ShyyRmlas1sh0\n33bOQRL/jCDNpGEHv+p6HdSpKi8NQxIJqh7LSzkb8KdQuTrtsBaGk0SmzTAhRINU78pf07U4n9Qr\n9AMWEBa1Yvm31elaLKwlAV4GA83kP4Ii7bbvkpq6djibJm/stZOaOqOMZtJkeTu5ua8sz2Rcf0U/\n/gflmB9xp3nBzQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "SOP form"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "Q = SOPform(['x', 'y', 'z'], minterms, dontcare)\n",
    "Q"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "podoc": {
     "output_text": "(True, False)"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgYAAABTBAMAAAAWzdL+AAAAMFBMVEX///92dnaIiIhUVFSYmJgi\nIiJERES6urpmZmYQEBDMzMwyMjLc3Nzu7u6qqqoAAAA1ApXJAAAAAXRSTlMAQObYZgAAAAlwSFlz\nAAAOxAAADsQBlSsOGwAACn9JREFUeNrlnF1sI0cdwCcfjj/ite/uoQ8I1TlRigQ9OWpFVYkPRyAe\nitTaiKrVcWo3VdWKckI+IYTgBQedBEFC+CiEtirVGvoAqpAcaJF6UlunBQ6u7dUppSqnXuug3kN5\n6Pny4SSO7/JnZnZ3Zta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A3diTbgT0fWonkcjALuzDjW8GEkHCSb/KQoExuJstB5LBmBMQxrV3\nQSUjshFIBjXn+Ye1d35kLezLgWSQdUNnZRdeVioH8/8rWE2W8s4M/GbFqSAiGOU1hGqZRWNotAKp\nBiFWK8UH/1Z7ZDmg7qDE0/5BO4Tqk8F0B5tCVTxoj1WZCCKCCPBHE7fWBnyzViDVoCyWYQUY7L/F\nyQbTFMwVT4yYHuS9wnv4prDPGPLOujjQkibxfCDVoN5qqx0C6bQGOmLQZqGV7X3H4GyjzQmOBNNk\nB5m6mi90JPS/2mcMQp2drcQ9+80UmAf8L3QVpUO2ORKzAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "(True, False)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "Q.subs({x: True, y: False, z: False}), Q.subs(\n",
    "    {x: False, y: True, z: True})"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
